#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int read() {
	int q=0;char ch=' ';
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') q=q*10+ch-'0',ch=getchar();
	return q;
}
#define RI register int
const int N=62,M=3605;
int n,m,tot,top,cnt,now;
int dfn[N],low[N],st[N],col[N],ins[N],opp[N],du[N],bj[N];
struct graph{
	int tot,h[N],to[M],ne[M];
	void add(int x,int y) {to[++tot]=y,ne[tot]=h[x],h[x]=tot;}
}G1,G2;
void tarjan(int x) {
	dfn[x]=low[x]=++now,st[++top]=x,ins[x]=1;
	for(RI i=G1.h[x];i;i=G1.ne[i])
		if(!dfn[G1.to[i]]) tarjan(G1.to[i]),low[x]=min(low[x],low[G1.to[i]]);
		else if(ins[G1.to[i]]) low[x]=min(low[x],dfn[G1.to[i]]);
	if(low[x]==dfn[x]) {
		++cnt;
		while(st[top]!=x) col[st[top]]=cnt,ins[st[top]]=0,--top;
		col[st[top]]=cnt,ins[st[top]]=0,--top;
	}
}
void topsort() {
	top=0;
	for(RI i=1;i<=cnt;++i) if(!du[i]) st[++top]=i;
	while(top) {
		int x=st[top];--top;
		if(!bj[x]) bj[x]=1,bj[opp[x]]=-1;
		for(RI i=G2.h[x];i;i=G2.ne[i]) {
			--du[G2.to[i]];
			if(!du[G2.to[i]]) st[++top]=G2.to[i];
		}
	}
}
void work() {
	for(RI i=1;i<=n*2;++i) if(!dfn[i]) tarjan(i);//缩点
	for(RI i=1;i<=n;++i) {//检查
		if(col[i]==col[i+n]) {puts("bad luck");return;}
		opp[col[i]]=col[i+n],opp[col[i+n]]=col[i];
	}
	for(RI x=1;x<=n*2;++x)//建新图
		for(RI i=G1.h[x];i;i=G1.ne[i])
			if(col[G1.to[i]]!=col[x])
			G2.add(col[G1.to[i]],col[x]),++du[col[x]];
	topsort();//拓扑排序处理
	for(RI i=1;i<n;++i)
		if(bj[col[i]]==-1) printf("%dh ",i);
		else printf("%dw ",i);
	puts("");
}
int main()
{
	int b1,b2;char c1,c2;
	while(~scanf("%d%d",&n,&m)&&(n+m)) {
		G1.tot=G2.tot=cnt=now=top=0;
		for(RI i=1;i<=n*2;++i) G1.h[i]=G2.h[i]=dfn[i]=ins[i]=du[i]=bj[i]=0;
		for(RI i=1;i<=m;++i) {
			scanf("%d%c%d%c",&b1,&c1,&b2,&c2);
			if(b1==0) b1=n; if(b2==0) b2=n;
			if(c1=='h'&&c2=='h') G1.add(b1,b2+n),G1.add(b2,b1+n);
			else if(c1=='h'&&c2=='w') G1.add(b1,b2),G1.add(b2+n,b1+n);
			else if(c1=='w'&&c2=='h') G1.add(b1+n,b2+n),G1.add(b2,b1);
			else G1.add(b1+n,b2),G1.add(b2+n,b1);
		}
		G1.add(2*n,n),work();
	}
	return 0;
}
